{% import 'macros/_commodity_macros.html' as commodity_macros %}


<p>
{{ _('Location') }}: <code><a href="{{ url_for_source(file_path=entry.meta.filename, line=entry.meta.lineno) }}" title="{{ _('Show source %(file)s:%(lineno)s', file=entry.meta.filename, lineno=entry.meta.lineno) }}">{{ entry.meta.filename }}:{{ entry.meta.lineno }}</a></code>
</p>
{% if balances %}
<details>
  <summary>
    <span>{{ _('Context') }}</span>
  </summary>
  <div>
    <table>
      <thead>
        <tr colspan=2>
          <th>{{ _('Balances before entry') }}<th>
        </tr>
      </thead>
      <tbody>
        {% for account, inventory in  balances[0].items() %}
        <tr>
          <td><a href="{{ url_for('account', name=account) }}">{{ account }}</a></td>
          <td>
            {% for position in inventory %}
              {{ commodity_macros.render_amount(ledger, position.units) }}
            {% if not loop.last %}<br>{% endif %}
            {% endfor %}
          </td>
        </tr>
        {% endfor %}
      </tbody>
    </table>
    <table>
      <thead>
        <tr colspan=2>
          <th>{{ _('Balances after entry') }}<th>
        </tr>
      </thead>
      <tbody>
        {% for account, inventory in  balances[1].items() %}
        <tr>
          <td><a href="{{ url_for('account', name=account) }}">{{ account }}</a></td>
          <td>
            {% for position in inventory %}
              {{ commodity_macros.render_amount(ledger, position.units) }}
            {% if not loop.last %}<br>{% endif %}
            {% endfor %}
          </td>
        </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
</details>
{% endif %}
